import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Inspect from 'vite-plugin-inspect'

const pathSrc = path.resolve(__dirname, 'src')

// https://vitejs.dev/config/
export default defineConfig({
	server: {
		open: true,
		port: 1314
	},
	plugins: [
		vue(),
		AutoImport({
			imports:[
				// 预设
				'vue',
			],
			resolvers: [
				// 自动导入element-plus组件
				ElementPlusResolver(),
				// Auto import icon components
				// 自动导入图标组件
				IconsResolver({
					prefix: 'Icon',
				}),
			],
			// dts: path.resolve(pathSrc, 'auto-imports.d.ts'),
		}),
		Components({
			resolvers: [
				// 自动注册element-plus组件
				ElementPlusResolver(),
				// 自动注册图标组件
				IconsResolver({
					enabledCollections: ['ep'],
				}),
			],
			// dts: path.resolve(pathSrc, 'auto-imports.d.ts'),
		}),
		// Icons({
		// 	autoInstall: true,
		// }),
		Inspect(),
	],
	resolve:{//路径别名
		alias:{
			'@': resolve(__dirname, pathSrc)
		}
	},
})